package com.joysuch.wwyt.common.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.LocalDateTime;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * @Author ZhangDong
 * @Date 2020/7/23 12:14
 */
@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_common_statics_report")
@SQLDelete(sql = "update wwyt_common_statics_report set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_common_statics_report set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
public class CommonStaticsReport {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Long id;

    @ApiModelProperty("关联人员表id")
    private Long userId;

    @ApiModelProperty("标题")
    private String title;

    @ApiModelProperty("全局标志位: 0 个人; 1 全局")
    private Integer allUserFlag;

    @ApiModelProperty("数据来源：0 现有业务; 1 外部链接")
    private Integer dataSources;

    @ApiModelProperty("外部链接URL")
    private String externalLink;

    @ApiModelProperty("图表集,对象格式：positionId: \"1-1\", gridNum: \"2-1\",chartId:1")
    private String chartList;

    //通用字段
    @ApiModelProperty("数据状态字段:0 无效; 1 有效")
    private Integer state;

    @org.springframework.data.annotation.CreatedBy
    @ApiModelProperty("创建人")
    @JsonIgnore
    private Long createBy;

    @org.springframework.data.annotation.CreatedDate
    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

    @org.springframework.data.annotation.LastModifiedBy
    @ApiModelProperty("更新人")
    @JsonIgnore
    private Long updateBy;

    @org.springframework.data.annotation.LastModifiedDate
    @ApiModelProperty("更新时间")
    @JsonIgnore
    private LocalDateTime updateTime;

    @ApiModelProperty("租户")
    private Long tenentId;

    @ApiModelProperty("组织机构代码")
    private String orgCode;

    @ApiModelProperty("删除标记")
    @JsonIgnore
    private String deleteFlag;
}
